<template>
  <section class="category-select-box">
    <a-spin :spinning="isLoading">
      <a-button style="margin:10px;" :type="selectedKey == category.id?'primary':'default'" v-for="(category,cIndex) in categoryList" :key="cIndex" @click="onTabClick(category)">{{category.name}}</a-button>
    </a-spin>
  </section>
</template>

<script>
import { findTreeList } from "../../../api/goodsType";

  export default {
    name:"SelectCategory",
    props:{
      selectedKey:{
        type:Number,
        default:0
      }
    },
    data(){
      return{
        isLoading:false,
        categoryList:[],
      }
    },
    methods:{
      onTabClick(category){
        this.$emit("result",category);
      },
      async loadBookCategory(){
        this.isLoading = true;
        let resp = await findTreeList();
        if(this.qUtil.validResp(resp)){
          this.categoryList = resp.data.dataList || [];
          console.log("=====>",this.categoryList)
        }
        this.isLoading = false;
      },
    },
    mounted(){
      this.loadBookCategory();
    }
  }
</script>

<style scoped>
  .category-select-box{
  }

</style>
